<?php
    class admin_providerManage_controller extends controllerBase
    {
        public function process()
        {
            $oDatabase = new database();
            
            if(isset($_POST['tb_provider_name']) && isset($_POST['tb_provider_alias']) && isset($_POST['tb_provider_homepage']) && isset($_POST['tb_provider_endpoint']) )
            {
                if($_POST['tb_provider_name'] != '' && $_POST['tb_provider_alias'] != '' && $_POST['tb_provider_homepage'] != '' && $_POST['tb_provider_endpoint'] != ''  )
                {
                    $aData = array(
                        'producer_name' => $_POST['tb_provider_name'],
                        'producer_alias' => $_POST['tb_provider_alias'],
                        'producer_homepage' => $_POST['tb_provider_homepage'],
                        'producer_endpoint' => $_POST['tb_provider_endpoint'],
                    );
                    $result = $oDatabase->add('producers',$aData);
                    if(!$result)
                    {
                        $this->aParams['error'] = "Add provider fail!";
                    }
                    else
                    {
                        $this->aParams['message'] = "Add provider susscessful!";
                    }
                }
                else
                {
                    $this->aParams['error'] = "Some field miss!";
                }
            }
            
            $sQuery = "SELECT * FROM producers";
            $this->aParams['aProviders'] = $oDatabase->getListObject($sQuery,true,true);
        }
    }
?>
